package com.yuchen.ishop.service.dictionary;


import com.yuchen.jaxrs.Responses;
import com.yuchen.jaxrs.restclient.RestClientUtils;
import com.yuchen.utils.config.ConfigUtils;
import org.springframework.stereotype.Service;

import javax.ws.rs.core.GenericType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class AddressRestClient {

    public List<Map> find(){
        String url = ConfigUtils.config.get("address_find");
        GenericType genericType =  new GenericType<List<Map>>() {};
        List<Map> json = RestClientUtils.get(genericType,url);
        return json;
    }

    public Responses findByParentId(String parentId){
        String url = ConfigUtils.config.get("address_findByParentId");
        parentId = parentId==null?"null":parentId;
        Map params = new HashMap(1);
        params.put("parentId",parentId);
        url =  RestClientUtils.url(url, params);

        return RestClientUtils.get(Responses.class,url);
    }
}
